package chart;

import java.awt.Shape;
import java.util.Vector;

/**
 * Multiple VerticalRing
 */
public class CompoundVerticalRing extends Ring
{

  protected Vector<VerticalRing> VerticalRings;

  public CompoundVerticalRing()
  {
    SegmentsInfo = new Vector<Segment>();
    segments = null;

    VerticalRings = new Vector<VerticalRing>();
  }

  public void AddVerticalRing(VerticalRing ar)
  {
    VerticalRings.add(ar);
    SegmentsInfo.addAll(ar.SegmentsInfo);
  }

  public void setCenter(double x, double y)
  {
    for (int i = 0; i < VerticalRings.size(); ++i)
    {
      VerticalRings.get(i).setCenter(x, y);
    }
  }

  public void setRadius(double radius)
  {
    for (int i = 0; i < VerticalRings.size(); ++i)
    {
      VerticalRings.get(i).setRadius(radius);
    }
  }

  public void setRingWidth(double width)
  {
    for (int i = 0; i < VerticalRings.size(); ++i)
    {
      VerticalRings.get(i).setRingWidth(width);
    }
  }

  public void createSegments()
  {
    int size = 0;
    for (int i = 0; i < VerticalRings.size(); ++i)
    {
      VerticalRings.get(i).createSegments();
      size += VerticalRings.get(i).count();
    }

    Shape[] shapes = new Shape[size];
    int index = 0;
    for (int i = 0; i < VerticalRings.size(); ++i)
    {
      VerticalRing ar = VerticalRings.get(i);
      for (int j = 0; j < ar.count(); ++j)
      {
        shapes[index] = ar.getSegment(j);
        index += 1;
      }
    }

    this.segments = shapes;
  }
}
